package Exam.String;

import java.util.Scanner;

public class StringD4_Login {
    public static void main(String[] args) {
        //一直正确的账号密码
        //实现模拟登录
        //总共三次机会，给出相应提示

        String rightUsername = "K_jiang";
        String rightPassword = "123456";

        for (int i = 2; i >= 0; i--) {
            //键盘录入账号密码
            Scanner sc = new Scanner(System.in);
            System.out.println("输入用户名：");
            String username = sc.next();
            System.out.println("输入密码：");
            String password = sc.next();

            //比较
            if (username.equals(rightUsername) && password.equals(rightPassword)) {
                System.out.println("成功登录,即将跳转");
                break;
            } else {
                if (i == 0) {
                    System.out.println("账号" + username + "被锁定，赶紧去点忘记密码吧~");
                } else {
                    System.out.println("账号或密码错误,还有" + i + "次机会");
                }
            }
        }


    }
}
